import Router from '@/router/index.js'
import nprogress from 'nprogress'// Progress 进度条引入
import 'nprogress/nprogress.css'// Progress 进度条样式
import { getToken } from '@/utils/auth.js'
Router.beforeEach((to, from, next) => {
  nprogress.start()
  // 路由拦截 --判断是否有token
  const token = getToken()
  if (token) {
    next()
  } else {
    if (to.path === '/login') {
      next()
    } else {
      next(`/login`)
    }
  }
  if (token && (to.path === '/login')) {
    console.log('那是花儿')
    next(`/`)
  }
  nprogress.done()
})
